package com.zd.zdMerchant.sys.web;

import com.zd.zdMerchant.common.web.BaseController;
import com.zd.zdMerchant.sys.dal.domain.Shop;
import com.zd.zdMerchant.sys.srv.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author zhangxiang
 * @Description
 * @date 2018/1/4 14:21
 */
@Controller
@RequestMapping("user")
public class UserController extends BaseController{

    @Autowired
    private ShopService shopService;

    @RequestMapping(value = "login",method = RequestMethod.POST)
    public String login(String phone, String password, Model model){
        Shop loginShop = shopService.login(phone, password);
        if(loginShop!=null){
            //登录成功
            model.addAttribute("loginShop",loginShop);
            return "index";
        }else{
            //失败
            model.addAttribute("message","用户名或密码错误");
            return "login";
        }
    }

}
